# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=rezolus
pkgver=2.11.1
pkgrel=3
pkgdesc="Systems performance telemetry"
url="https://github.com/twitter/rezolus/"
arch="x86_64 x86 armv7 armhf aarch64 ppc64le"  # limited by rust/cargo
license="Apache-2.0"
makedepends="cargo openssl-dev cargo-auditable"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc $pkgname-doc"
source="https://github.com/twitter/rezolus/archive/v$pkgver/rezolus-$pkgver.tar.gz
	minimize-size.patch
	remove-ntp-sampler.patch
	remove-http-sampler.patch
	openssl.patch
	config.toml
	$pkgname.initd
	$pkgname.confd
	$pkgname.logrotate
	"


prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/rezolus -t "$pkgdir"/usr/bin/

	install -Dm 644 "$srcdir"/config.toml "$pkgdir"/etc/rezolus.toml

	install -Dm 755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm 644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -Dm 644 "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname

	install -Dm 644 configs/example.toml "$pkgdir"/usr/share/doc/$pkgname/full-config.toml
}

sha512sums="
8ffe293cb197e0b2a6f5ba4bf7bdf7f77528f30785e64e15774241279309e881a6898b8f1bae7b6bfdc2f7dcd3e54793b249673aa0e25bcdbdb50f100fa3864d  rezolus-2.11.1.tar.gz
952e03a6b41fc57727099c9a913632f967f7355d89cf0553c36ea9f959bcc934bcc1daba6d8dd22e9a40b95e6a1ca62f41f61f724b3399b9b78022565ea015e6  minimize-size.patch
0dca295df00aff5b1f951b204dbddfe29f6ce353833076bd9ea676ad1f5650a24d6d6a46fb69e366c2ba899bb3c53163a99aa49c356aaab5f6c57a5f0f28143f  remove-ntp-sampler.patch
bfc805dd2cf268549d8d9f3c98dd6a66152f6088eabcdcee5afabaa0dc03743b1dd936f97f6d6b36f8da081cd8915191156ca0b20ba2d92c3b6742cfd02cdfb1  remove-http-sampler.patch
27cfa9a21fffaf81d75619a10fb30c3bdef72b7b1041932f7919f15153fd2a04a2d133f37a3815f28391c1f5440710e6b7022cc41f896ffa66b441dc42383186  openssl.patch
35b883ab2c01a00019064cb7cb9ca28ddf469175f46e8cba15b62eef5519979fd63d2b180a50fad896de07ebeb6172f76c7d61d4e8ae2ce72c06b34d7462ac38  config.toml
17ba0039a84287a2183f398756cac0cb43f0de2ac95911fa41fcd5bb7b3f411aa8a174632ffa4a519fabd4edd25d69fa2ffa52711fcf0c32c0e1e55eb4828e7b  rezolus.initd
cbc3600b6a01142acb0f4f47a07ee1ad94222f3bd4106e2e29d7cb5edf23bfc54b40fd5d0ab616d0a22a9bca7a10dd1832f23589daeee195a628d25f0a0d21d3  rezolus.confd
248f447686af4b69ebfc1558029babc2aab83cdf50b0cc22c1306549c37f7448a5ed4ebd0cc216f17701b93ea37655e856360e428c7c84eec5d2a64ca3fe178e  rezolus.logrotate
"
